package com.core.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.common.ibatis.BaseDao;
import com.core.entity.User;
import com.core.entity.UserExample;
@Repository
public class UserDAOImpl extends BaseDao implements UserDAO {

    public UserDAOImpl() {
        super();
    }

   
    public void insert(User record) {
        getSqlMapClientTemplate().insert("user.abatorgenerated_insert", record);
    }

   
    public int updateByPrimaryKey(User record) {
        int rows = getSqlMapClientTemplate().update("user.abatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    
    public int updateByPrimaryKeySelective(User record) {
        int rows = getSqlMapClientTemplate().update("user.abatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

   
    public List selectByExample(UserExample example) {
        List list = getSqlMapClientTemplate().queryForList("user.abatorgenerated_selectByExample", example);
        return list;
    }

    public User selectByPrimaryKey(Integer id) {
        User key = new User();
        key.setId(id);
        User record = (User) getSqlMapClientTemplate().queryForObject("user.abatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    public int deleteByExample(UserExample example) {
        int rows = getSqlMapClientTemplate().delete("user.abatorgenerated_deleteByExample", example);
        return rows;
    }

   
    public int deleteByPrimaryKey(Integer id) {
        User key = new User();
        key.setId(id);
        int rows = getSqlMapClientTemplate().delete("user.abatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    
    public int countByExample(UserExample example) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("user.abatorgenerated_countByExample", example);
        return count.intValue();
    }

   
    public int updateByExampleSelective(User record, UserExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("user.abatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    
    public int updateByExample(User record, UserExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("user.abatorgenerated_updateByExample", parms);
        return rows;
    }

   
    private static class UpdateByExampleParms extends UserExample {
        private Object record;

        public UpdateByExampleParms(Object record, UserExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}